package d6_pool;

import java.util.concurrent.*;

public class t1 {
    public static void main(String[] args) {
        ExecutorService pool = new ThreadPoolExecutor(3,5,8, TimeUnit.SECONDS,new LinkedBlockingQueue<Runnable>(2),
                Executors.defaultThreadFactory(),new ThreadPoolExecutor.CallerRunsPolicy());
        Runnable target = new MyRunnable();
        pool.execute(target);//创建
        pool.execute(target);//创建
        pool.execute(target);//创建
        pool.execute(target);//复用(等待)
        pool.execute(target);//复用(等待)
        pool.execute(target);//临时
        pool.execute(target);//临时
        pool.execute(target);

//        pool.shutdown();
//        pool.shutdownNow();

    }
}
